package tr.gov.tubitak.bilgem.esya.certviewer;

import tr.gov.tubitak.bilgem.esya.certviewer.viwerasn.ECertField;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableModel;
import java.awt.*;

import static tr.gov.tubitak.bilgem.esya.certviewer.viwerasn.ECertField.*;
import static tr.gov.tubitak.bilgem.esya.certviewer.viwerasn.ECertField.ECertFieldType.*;

/**
 * Created by IntelliJ IDEA.
 * User: ramazan.girgin
 * Date: 07.12.2011
 * Time: 11:39
 * To change this template use File | Settings | File Templates.
 */
public class ECertFieldTableRenderer extends DefaultTableCellRenderer{
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        Component comp = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);    //To change body of overridden methods use File | Settings | File Templates.
        if(column == 0)
        {
            ECertField rowElement = (ECertField) value;
            setText(((ECertField) value).getTitle());
            switch (rowElement.getFieldType())
            {
                case BASIC_V1:
                    setIcon(EImageManager.getInstance().getImageIcon("v1Field.png","V1Field_Icon"));
                    break;
                case EXTENSION:
                    setIcon(EImageManager.getInstance().getImageIcon("extensionField.png","V1Field_Icon"));
                    break;
                case CRITICAL_EXTENSION:
                    setIcon(EImageManager.getInstance().getImageIcon("criticalExtensionField.png","V1Field_Icon"));
                    break;
                default:
                    setIcon(new ImageIcon());
            };
        }
        return comp;
    }
}
